/******************************************************************************* 
 *  Copyright 2007 Amazon Technologies, Inc.  
 *  Licensed under the Apache License, Version 2.0 (the "License"); 
 *  
 *  You may not use this file except in compliance with the License. 
 *  You may obtain a copy of the License at: http://aws.amazon.com/apache2.0
 *  This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 
 *  CONDITIONS OF ANY KIND, either express or implied. See the License for the 
 *  specific language governing permissions and limitations under the License.
 * ***************************************************************************** 
 *    __  _    _  ___ 
 *   (  )( \/\/ )/ __)
 *   /__\ \    / \__ \
 *  (_)(_) \/\/  (___/
 * 
 *  Amazon ECS CSharp Library
 *  API Version: 2007-07-16
 *  Generated: Thu Aug 02 10:15:38 PDT 2007 
 * 
 */

using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using System.Text;


namespace Amazon.ECS.Model
{
    [XmlTypeAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16")]
    [XmlRootAttribute(Namespace = "http://webservices.amazon.com/AWSECommerceService/2007-07-16", IsNullable = false)]
    public class Merchant
    {
    
        private String merchantIdField;

        private String nameField;

        private String glancePageField;

        private Decimal? averageFeedbackRatingField;

        private Decimal? totalFeedbackField;

        private Decimal? totalFeedbackPagesField;


        /// <summary>
        /// Gets and sets the MerchantId property.
        /// </summary>
        [XmlElementAttribute(ElementName = "MerchantId")]
        public String MerchantId
        {
            get { return this.merchantIdField ; }
            set { this.merchantIdField= value; }
        }



        /// <summary>
        /// Sets the MerchantId property
        /// </summary>
        /// <param name="merchantId">MerchantId property</param>
        /// <returns>this instance</returns>
        public Merchant WithMerchantId(String merchantId)
        {
            this.merchantIdField = merchantId;
            return this;
        }



        /// <summary>
        /// Checks if MerchantId property is set
        /// </summary>
        /// <returns>true if MerchantId property is set</returns>
        public Boolean IsSetMerchantId()
        {
            return  this.merchantIdField != null;

        }


        /// <summary>
        /// Gets and sets the Name property.
        /// </summary>
        [XmlElementAttribute(ElementName = "Name")]
        public String Name
        {
            get { return this.nameField ; }
            set { this.nameField= value; }
        }



        /// <summary>
        /// Sets the Name property
        /// </summary>
        /// <param name="name">Name property</param>
        /// <returns>this instance</returns>
        public Merchant WithName(String name)
        {
            this.nameField = name;
            return this;
        }



        /// <summary>
        /// Checks if Name property is set
        /// </summary>
        /// <returns>true if Name property is set</returns>
        public Boolean IsSetName()
        {
            return  this.nameField != null;

        }


        /// <summary>
        /// Gets and sets the GlancePage property.
        /// </summary>
        [XmlElementAttribute(ElementName = "GlancePage")]
        public String GlancePage
        {
            get { return this.glancePageField ; }
            set { this.glancePageField= value; }
        }



        /// <summary>
        /// Sets the GlancePage property
        /// </summary>
        /// <param name="glancePage">GlancePage property</param>
        /// <returns>this instance</returns>
        public Merchant WithGlancePage(String glancePage)
        {
            this.glancePageField = glancePage;
            return this;
        }



        /// <summary>
        /// Checks if GlancePage property is set
        /// </summary>
        /// <returns>true if GlancePage property is set</returns>
        public Boolean IsSetGlancePage()
        {
            return  this.glancePageField != null;

        }


        /// <summary>
        /// Gets and sets the AverageFeedbackRating property.
        /// </summary>
        [XmlElementAttribute(ElementName = "AverageFeedbackRating")]
        public Decimal AverageFeedbackRating
        {
            get { return this.averageFeedbackRatingField.GetValueOrDefault() ; }
            set { this.averageFeedbackRatingField= value; }
        }



        /// <summary>
        /// Sets the AverageFeedbackRating property
        /// </summary>
        /// <param name="averageFeedbackRating">AverageFeedbackRating property</param>
        /// <returns>this instance</returns>
        public Merchant WithAverageFeedbackRating(Decimal averageFeedbackRating)
        {
            this.averageFeedbackRatingField = averageFeedbackRating;
            return this;
        }



        /// <summary>
        /// Checks if AverageFeedbackRating property is set
        /// </summary>
        /// <returns>true if AverageFeedbackRating property is set</returns>
        public Boolean IsSetAverageFeedbackRating()
        {
            return  this.averageFeedbackRatingField != null;

        }


        /// <summary>
        /// Gets and sets the TotalFeedback property.
        /// </summary>
        [XmlElementAttribute(ElementName = "TotalFeedback")]
        public Decimal TotalFeedback
        {
            get { return this.totalFeedbackField.GetValueOrDefault() ; }
            set { this.totalFeedbackField= value; }
        }



        /// <summary>
        /// Sets the TotalFeedback property
        /// </summary>
        /// <param name="totalFeedback">TotalFeedback property</param>
        /// <returns>this instance</returns>
        public Merchant WithTotalFeedback(Decimal totalFeedback)
        {
            this.totalFeedbackField = totalFeedback;
            return this;
        }



        /// <summary>
        /// Checks if TotalFeedback property is set
        /// </summary>
        /// <returns>true if TotalFeedback property is set</returns>
        public Boolean IsSetTotalFeedback()
        {
            return  this.totalFeedbackField != null;

        }


        /// <summary>
        /// Gets and sets the TotalFeedbackPages property.
        /// </summary>
        [XmlElementAttribute(ElementName = "TotalFeedbackPages")]
        public Decimal TotalFeedbackPages
        {
            get { return this.totalFeedbackPagesField.GetValueOrDefault() ; }
            set { this.totalFeedbackPagesField= value; }
        }



        /// <summary>
        /// Sets the TotalFeedbackPages property
        /// </summary>
        /// <param name="totalFeedbackPages">TotalFeedbackPages property</param>
        /// <returns>this instance</returns>
        public Merchant WithTotalFeedbackPages(Decimal totalFeedbackPages)
        {
            this.totalFeedbackPagesField = totalFeedbackPages;
            return this;
        }



        /// <summary>
        /// Checks if TotalFeedbackPages property is set
        /// </summary>
        /// <returns>true if TotalFeedbackPages property is set</returns>
        public Boolean IsSetTotalFeedbackPages()
        {
            return  this.totalFeedbackPagesField != null;

        }




        /// <summary>
        /// XML fragment representation of this object
        /// </summary>
        /// <returns>XML fragment for this object.</returns>
        /// <remarks>
        /// Name for outer tag expected to be set by calling method. 
        /// This fragment returns inner properties representation only
        /// </remarks>


        protected internal String ToXMLFragment() {
            StringBuilder xml = new StringBuilder();
            if (IsSetMerchantId()) {
                xml.Append("<MerchantId>");
                xml.Append(EscapeXML(this.MerchantId));
                xml.Append("</MerchantId>");
            }
            if (IsSetName()) {
                xml.Append("<Name>");
                xml.Append(EscapeXML(this.Name));
                xml.Append("</Name>");
            }
            if (IsSetGlancePage()) {
                xml.Append("<GlancePage>");
                xml.Append(EscapeXML(this.GlancePage));
                xml.Append("</GlancePage>");
            }
            if (IsSetAverageFeedbackRating()) {
                xml.Append("<AverageFeedbackRating>");
                xml.Append(this.AverageFeedbackRating);
                xml.Append("</AverageFeedbackRating>");
            }
            if (IsSetTotalFeedback()) {
                xml.Append("<TotalFeedback>");
                xml.Append(this.TotalFeedback);
                xml.Append("</TotalFeedback>");
            }
            if (IsSetTotalFeedbackPages()) {
                xml.Append("<TotalFeedbackPages>");
                xml.Append(this.TotalFeedbackPages);
                xml.Append("</TotalFeedbackPages>");
            }
            return xml.ToString();
        }

        /**
         * 
         * Escape XML special characters
         */
        private String EscapeXML(String str) {
            StringBuilder sb = new StringBuilder();
            foreach (Char c in str)
            {
                switch (c) {
                case '&':
                    sb.Append("&amp;");
                    break;
                case '<':
                    sb.Append("&lt;");
                    break;
                case '>':
                    sb.Append("&gt;");
                    break;
                case '\'':
                    sb.Append("&#039;");
                    break;
                case '"':
                    sb.Append("&quot;");
                    break;
                default:
                    sb.Append(c);
                    break;
                }
            }
            return sb.ToString();
        }




    }

}